<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<div th:replace="common/common::html"></div>
<head>
    <meta charset="UTF-8">
    <script th:inline="javascript">
        $(function () {
            //权限对话框
            $("#resouce-alc-dialog-id").dialog({
                autoOpen : false,
                width : 600,
                modal : true,
                resizable : false,
                title: /*[[#{file.resouce.acl.dialog}]]*/'',
                buttons: [
                    {
                        text: /*[[#{common.confirm}]]*/'',
                        click: function() {
                            var fileUuid = $("#resouce-alc-dialog-id").attr("fileUuid");
                            var aclArray = [];
                            var ztreeObj = $.fn.zTree.getZTreeObj("resouce-alc-ztree-id");
                            var nodes = ztreeObj.getCheckedNodes(true);
                            $(nodes).each(function (index,item) {
                                aclArray.push(item.id);
                            })

                            $.ajax({
                                type: 'post',
                                async: false,
                                dataType : 'json',
                                url: /*[[@{setObjectAcl}]]*/'',
                                data: [
                                    {
                                        name:"fileUuid",
                                        value:fileUuid
                                    },
                                    {
                                        name:"aclArray",
                                        value:aclArray
                                    },
                                ],
                                success: function (data) {
                                    message(data.msg);
                                    $("#resouce-alc-dialog-id").dialog('close');
                                },
                                error: function(msg){
                                    message(/*[[#{common.error}]]*/'');
                                }
                            });
                        }
                    },
                    {
                        text: /*[[#{common.cancel}]]*/'',
                        click: function() {
                            $( this ).dialog( "close" );
                        }
                    }]
            });
        });//ready方法
        //资源访问
        function resouceAcl(fileUuid) {
            //alert(fileUuid);
            $("#resouce-alc-dialog-id").dialog('open');
            loadAclZtree(fileUuid);
        }
        var aclSetting = {
            check: {

                enable: true
            },
            data: {
                simpleData: {
                    enable: true
                }
            }
        };

        //加载ztree资源访问
        function loadAclZtree(fileUuid) {
            $("#resouce-alc-dialog-id").attr("fileUuid",fileUuid);
            $.ajax({
                type: 'post',
                async: false,
                dataType : 'json',
                url: /*[[@{queryAclZtree}]]*/'',
                data: [
                    {
                        name:"fileUuid",
                        value:fileUuid
                    }
                ],
                success: function (data) {
                    $.fn.zTree.init($("#resouce-alc-ztree-id"), aclSetting, data);
                    $("#resouce-alc-dialog-id").dialog('open');
                },
                error: function(msg){
                    message(/*[[#{common.error}]]*/'');
                }
            });
        }

    </script>
</head>
<body>
<!--访问权限-->
<div id="resouce-alc-dialog-id" style="display: none">
    <ul id="resouce-alc-ztree-id" class="ztree"></ul>
</div>





</body>
</html>